from django.db import models

# Create your models here.
class TicketConf(models.Model):
    url_status = ((True, 'normal'), (False, 'abnormal'))
    name = models.CharField(max_length=20, verbose_name="名称", null=False, blank=False)
    url = models.CharField(max_length=1024, verbose_name="数据源路由")
    params = models.CharField(max_length=1024,verbose_name="其他参数")
    other = models.CharField(max_length=1024,verbose_name="其他信息")
    status = models.BooleanField(choices=url_status,verbose_name="状态")
    des_table = models.CharField(max_length=20,verbose_name="目标数据表", null=False, blank=False)
    create_date = models.DateTimeField(verbose_name="创建时间", auto_now_add=True)
    update_date = models.DateTimeField(verbose_name="更新时间", auto_now=True)

class Seven_star_ticket(models.Model):
    data_class=((0,'publish'),(1,'prognosis'))
    pre_data=(0,1,2,3,4,5,6,7,8,9)
    suf_data=(*pre_data,10,11,12,13,14)
    name = models.CharField(max_length=20, verbose_name="名称", null=False, blank=False)
    data_class = models.SmallIntegerField(choices=data_class, verbose_name='数据类别',default=0)
    publish_num = models.IntegerField(verbose_name="期数")
    e1 = models.SmallIntegerField(choices=zip(pre_data,pre_data), verbose_name="element 1")
    e2 = models.SmallIntegerField(choices=zip(pre_data,pre_data), verbose_name="element 2")
    e3 = models.SmallIntegerField(choices=zip(pre_data,pre_data), verbose_name="element 3")
    e4 = models.SmallIntegerField(choices=zip(pre_data,pre_data), verbose_name="element 4")
    e5 = models.SmallIntegerField(choices=zip(pre_data,pre_data), verbose_name="element 5")
    e6 = models.SmallIntegerField(choices=zip(pre_data,pre_data), verbose_name="element 6")
    e7 = models.SmallIntegerField(choices=zip(suf_data,suf_data), verbose_name="element 7")
    create_date = models.DateTimeField(verbose_name="创建时间", auto_now_add=True)
    publish_date = models.DateTimeField(verbose_name="发布时间")

    def get_index(self):
        return self.publish_num
    def get_value(self):
        return {"e1":self.e1,"e2":self.e2,"e3":self.e3,"e4":self.e4,"e5":self.e5,"e6":self.e6,"e7":self.e7}
    def __str__(self):
        return "{} {} {} {} {} {} {} {} {} {} {}".format(self.name,self.publish_num,self.e1,self.e2,self.e3,self.e4,self.e5,self.e6,self.e7,self.publish_date,self.data_class)